<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>变量的解构赋值</title>
</head>
<body>
<script>
    // 1. 数组的解构
    // const name=['张三','李四','王五']
    // const [zhangSan,liSi,wangWu]=name
    // console.log(zhangSan,liSi,wangWu)

    //对象的解构
    const obj = {
        name: '张三',
        age: 16,
        sex: 'woman',
        fun: func
    }

    function func() {
        console.log('hello!')
    }

    let {name, age, sex, fun} = obj
    console.log(name, age, sex, fun)
    fun();//调用
</script>
</body>
</html>